package com.naizhuai.util;

/**
 * Created by code_han on 2018/5/16.
 */

public class HideNumberUtils {

    /**
     * 隐藏电话号码中间四位
     * @param number
     * @return
     */
    public static String hidePhoneNumber(String number){
        return number.replaceAll("(\\d{3})\\d{4}(\\d{4})", "$1****$2");
    }

    /**
     * 隐藏邮箱：只显示@前面的首位和末位
     * @param email
     * @return
     */
    public static String hideEmailString(String email){
        return email.replaceAll("(\\w?)(\\w+)(\\w)(@\\w+\\.[a-z]+(\\.[a-z]+)?)", "$1****$3$4");
    }

}
